package com.hice.demo.dubbo.api.service;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.annotation.Service;
import com.hice.demo.dubbo.message.service.MessageService;
import com.hice.demo.dubbo.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author hyson
 * @create 2017-03-14 11:58
 */
@Slf4j
@Service
public class ServiceTestImpl implements ServiceTest {
    @Reference(version = "1.0.0")
    UserService userService;
    @Reference(version = "1.0.0")
    MessageService messageService;

    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    @Override
    public boolean dubboDel(Long id) {
        boolean result = true;
        try {
            log.info("删除用户{}", userService.del(id));
            System.out.println(1/0);
            log.info("删除用户信息{}", messageService.del(id));
        }catch (Exception e){
            log.info("异常{}", e.getMessage());
            result = false;
        }
        return result;
    }
}
